package br.com.salaodebeleza.view;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import br.gov.frameworkdemoiselle.annotation.PreviousView;
import br.gov.frameworkdemoiselle.stereotype.ViewController;
import br.gov.frameworkdemoiselle.template.AbstractEditPageBean;
import br.gov.frameworkdemoiselle.transaction.Transactional;
import br.com.salaodebeleza.business.TbServicosBC;
import br.com.salaodebeleza.domain.TbServicos;
import br.com.salaodebeleza.validator.ValidarEspaçoEmBranco;

@ViewController
@PreviousView("./tbServicos_list.jsf")
public class TbServicosEditMB extends AbstractEditPageBean<TbServicos, Long> {

	private static final long serialVersionUID = 1L;

	@Inject
	private TbServicosBC tbServicosBC;
	
	@Override
	@Transactional
	public String delete() {
		this.tbServicosBC.delete(getId());
		return getPreviousView();
	}
	
	@Override
	@Transactional
	public String insert() {
		this.tbServicosBC.insert(getBean());
		return getPreviousView();
	}
	
	@Override
	@Transactional
	public String update() {
		this.tbServicosBC.update(getBean());
		return getPreviousView();
	}
	
	@Override
	protected void handleLoad() {
		setBean(this.tbServicosBC.load(getId()));
	}
	
	public void validarEspacoBranco(FacesContext context, UIComponent componet, Object object){
		
		ValidarEspaçoEmBranco valida = new ValidarEspaçoEmBranco();
		
		valida.validarEspacoBranco(context, componet, object);
	}
	
}